{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f720274b-7e4f-4c35-9a6c-93026bb8a79b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入半径：  2\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "圆的周长 = 12.57\n",
      "圆的面积 = 12.57\n",
      "球的表面积 = 50.27\n",
      "球的体积 = 33.51\n"
     ]
    }
   ],
   "source": [
    "from math import *\n",
    "class MyMath:\n",
    "    global PI\n",
    "    PI  = 3.1415926\n",
    "    def Perimeter(r):\n",
    "        return (2 * PI * r)\n",
    "    def Area(r):\n",
    "        return (PI * r * r)\n",
    "    def Surface(r):\n",
    "        return (4*PI * r * r)\n",
    "    def Volume(r):\n",
    "        return( 4 * PI * pow(r, 3) / 3)\n",
    "r = float(input(\"请输入半径： \"))\n",
    "print(str.format(\"圆的周长 = {0:2.2f}\", MyMath.Perimeter(r)))\n",
    "print(str.format(\"圆的面积 = {0:2.2f}\", MyMath.Area(r)))\n",
    "print(str.format(\"球的表面积 = {0:2.2f}\", MyMath.Surface(r)))\n",
    "print(str.format(\"球的体积 = {0:2.2f}\", MyMath.Volume(r)))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9886b8c4-b135-4820-bfa3-d17eee38de3a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
